<template>
  <a-modal title-align="start" title="审核" :mask-closable="false" v-model:visible="showvisible" @cancel="showvisible = false" :width="400">
    <a-radio-group v-model="agree">
      <a-radio :value="true">通过</a-radio>
      <a-radio :value="false">拒绝</a-radio>
    </a-radio-group>
    <template #footer class="modal-footer">
      <a-button @click="showvisible = false">取消</a-button>
      <a-button type="primary" :loading="loading" @click="submit">确定</a-button>
    </template>
  </a-modal>
</template>

<script lang="ts" setup>
  import { defineComponent, ref, computed, onMounted } from 'vue'
  import { versionBatchAudit } from '@/api/product'
  import { Message } from '@arco-design/web-vue'
  let props = defineProps(['modelValue', 'type', 'ids'])
  let emits = defineEmits(['save', 'update:modelValue'])
  const formRef = ref()
  let showvisible = computed({
    get() {
      return props.modelValue
    },
    set(val) {
      emits('update:modelValue', val)
    },
  })

  let loading = ref(false)
  let agree = ref(true)

  const submit = async () => {
    // const valid = await formRef.value.validate()
    // if (valid) return
    try {
      loading.value = true
      const res: any = await versionBatchAudit({ agree: agree.value, idList: props.ids })
      if (res) {
        Message.success('操作成功')
        emits('save', res)
      }
      showvisible.value = false
    } catch (error) {}
    loading.value = false
  }
</script>

<style lang="less" scoped></style>
